﻿using System;

namespace NASA.BeAMartian.Plugin
{
    public class XapDownloadCompletedEventArgs : XapEventArgs
    {
        public XapDownloadCompletedEventArgs(Uri xapUri, object userToken, bool canceled, Exception ex)
            : base(xapUri, userToken)
        {
            this.Canceled = canceled;
            this.Exception = ex;
        }

        public bool Canceled { get; private set; }

        public Exception Exception { get; private set; }

        public override Uri XapUri
        {
            get
            {
                if (this.Exception != null)
                {
                    throw this.Exception;
                }

                return base.XapUri;
            }

            protected set
            {
                base.XapUri = value;
            }
        }
    }
}
